{
  //声明一个接口
  interface BoyFriend{
    name: string;
    age: number;
    car?: string;
    readonly id: number;
    //声明一个方法
    cook?: () => void;
    //声明方法的另一种写法
    // cook?(): void;
  }

  //声明一个对象
  let obj: BoyFriend = {
    id: 1,
    name: '易烊千玺',
    age: 23,
    cook(){
      console.log('煮方便面...');
    }
  };

  let obj2: BoyFriend = {
    id: 2,
    name: '王俊凯',
    age: 24
  }

  function fn(arg: BoyFriend){
    arg.age
  }
  // obj.id = 2;
}

{

  interface BaseInfo{
    name: string;
    age: number;
  }

  //男朋友
  interface BoyFriend extends BaseInfo{
    car: string;
    house ?: string;
    earn: () => void;
  }
  //员工
  interface Stuff extends BaseInfo{
    program: (language: string) => void;
  }

  //implements 实现   了解
  class GeGe implements BoyFriend, Stuff{
    name: string;
    age: number;
    car: string;
    house?: string;
    //添加属于自己类的属性
    shuai: string = '很帅~~';

    constructor(name: string, age: number, car: string, house?: string){
      this.name = name;
      this.age = age;
      this.car = car;
      this.house = house;
    }
    earn(){
      console.log('能挣钱....');
    }

    program(language: string){
      console.log(`我可以编写 ${language} 程序`);
    }

    //唱
    sing(){

    }
  }

  //实例化
  let syp = new GeGe('苏有朋', 39, 'xxx', '房子');
  let dingzhen = new GeGe('丁真', 36, 'xxx', 'xxx');

  syp.program('JavaScript');
  dingzhen.program('CSS');

}

{
  //接口的多次声明
  interface Inter{
    a: string;
    b: string;
  }

  interface Inter{
    c: string;
    d: string;
  }

  //声明一个对象
  let obj: Inter = {
    a: 'aaa',
    b: 'bbb',
    c: 'ccc',
    d: 'dddd'
  }
}